﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Subgurim.Controles;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;

namespace BL
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //insert code here that you only want to run the first time this page is loaded
                Initialize();
            }
            
        }
        public void Initialize()
        {
            GMap1.Height = 500;
            GMap1.Width = 900;
            GMap1.GZoom = 3;
            GLatLng center = new GLatLng(39.011902, -98.4842465);
            GMap1.setCenter(center);

            GMapUIOptions options = new GMapUIOptions();
            options.controls_largemapcontrol3d = true;
            options.controls_scalecontrol = true;
            options.zoom_scrollwheel = true;
            options.controls_scalecontrol = true;
            options.keyboard = true;
            GMap1.Add(new GMapUI(options));

            BL.StoreBL storeBL = new BL.StoreBL();
            storeBL.LoadStoresOnMap(GMap1);


 
        }

        protected void BtnFind_Click(object sender, EventArgs e)
        {
            string Key = System.Configuration.ConfigurationManager.AppSettings.Get("googlemaps.subgurim.net");
            string addressInput = TxtAddress.Text;
            int radiusInput = Convert.ToInt32(RadiusList.SelectedValue);

            GeoCode geoCode = GMap.geoCodeRequest(addressInput, Key);
            Double latt = geoCode.Placemark.coordinates.lat;
            Double longg = geoCode.Placemark.coordinates.lng;
            GLatLng point = new GLatLng(latt, longg);
            //GMarker marker = new GMarker(new GLatLng(latt, longg));
            ////GMap1.addGMarker(marker);
            //GInfoWindow info = new GInfoWindow(marker, "Your Location:" + addressInput);
            //GMap1.Add(info);
            GMap1.setCenter(point, radiusInput);
        }

    }
}
